package com.dev.dream.libs.preperences;

import java.util.Set;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.Preference;
import android.util.AttributeSet;

@SuppressLint("NewApi") public class DevDreamPreferenceManager {

	private SharedPreferences mSharedPreferences;
	private SharedPreferences.Editor mSharedPreferencesEditor;

	public DevDreamPreferenceManager(Context mContext, String PREFERENCE_NAME) {
		if (mSharedPreferences == null) {

			mSharedPreferences = mContext.getSharedPreferences(PREFERENCE_NAME,
					Context.MODE_PRIVATE);

			mSharedPreferencesEditor = mSharedPreferences.edit();
		}
	}

	public boolean getBoolean(String key, boolean defValue) {
		return mSharedPreferences.getBoolean(key, defValue);

	}

	public float getFloat(String key, float defValue) {
		return mSharedPreferences.getFloat(key, defValue);

	}

	public int getInt(String key, int defValue) {

		return mSharedPreferences.getInt(key, defValue);
	}

	public Long getLong(String key, long defValue) {
		return mSharedPreferences.getLong(key, defValue);

	}

	public String getString(String key, String defValue) {
		return mSharedPreferences.getString(key, defValue);

	}

	@SuppressLint("NewApi") public Set<String> getStringSet(String key, Set<String> defValue) {
		return mSharedPreferences.getStringSet(key, defValue);

	}

	public void putBoolean(String key, boolean value) {
		mSharedPreferencesEditor.putBoolean(key, value);
		mSharedPreferencesEditor.commit();
	}

	public void putFloat(String key, float value) {
		mSharedPreferencesEditor.putFloat(key, value);
		mSharedPreferencesEditor.commit();
	}

	public void putInt(String key, int value) {
		mSharedPreferencesEditor.putInt(key, value);
		mSharedPreferencesEditor.commit();
	}

	public void putLong(String key, Long value) {
		mSharedPreferencesEditor.putLong(key, value);
		mSharedPreferencesEditor.commit();
	}

	public void putString(String key, String value) {
		mSharedPreferencesEditor.putString(key, value);
		mSharedPreferencesEditor.commit();
	}

	public void putStringSet(String key, Set<String> value) {
		mSharedPreferencesEditor.putStringSet(key, value);
		mSharedPreferencesEditor.commit();
	}

}
